package demoPkg;
import java.sql.*;
import java.lang.*;

public class dbConn
{
	private Connection conn;
	public void dbConn(){
		this.conn = null;
		String url = "jdbc:mysql://localhost:3306/java_prj_db";
		
		try{
			Class.forName("com.mysql.jdbc.Driver").newInstance();
			conn = DriverManager.getConnection(url,"root","1111");
		}
		catch(Throwable e){
			//return e.toString();
			//wejfoiewjfoiew
		}
	}
	public String dbConnFunc()
	{
		
		int insCnt = 0;
		Statement stmt = this.conn.createStatement();
		PreparedStatement pstmt;
		//pstmt = conn.prepareStatement("");
		insCnt = stmt.executeUpdate("INSERT INTO phone_book (name,phone)" + "VALUES('LKH','02-123-1234')");
		System.out.println(insCnt + "rows were inserted");
		stmt.close();

		return "Mysql~~~";
	}
	public void closeDB(){
		this.conn.close();
	}
}